package com.yaodian100.mall.alipay;

import java.io.UnsupportedEncodingException;

import org.apache.commons.lang.StringUtils;
import org.apache.geronimo.mail.util.Base64;

import com.opensymphony.xwork2.ActionSupport;
import com.yaodian100.core.common.utils.ServerValue;

/**
 * 
 * @author apple.chang
 * 
 */
public class AlipayAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8669717234159046996L;

	private String redirect_url;
	private String target_url;

	public String toAlipayLogin() throws UnsupportedEncodingException {
		if (StringUtils.isBlank(redirect_url)) {
			redirect_url = ServerValue.getFrontHostname() + ServerValue.getFrontContextPath() + "/member/myyaodian.do";
		}
		redirect_url = new String(Base64.encode(redirect_url.getBytes()));
		return "toAlipayLogin";
	}

	public String alipayReturn() {
		if (StringUtils.isBlank(target_url)) {
			target_url = ServerValue.getFrontHostname() + ServerValue.getFrontContextPath() + "/member/myyaodian.do";
		}
		target_url = new String(Base64.encode(target_url.getBytes()));
		return "alipayReturn";
	}

	public String getRedirect_url() {
		return redirect_url;
	}

	public void setRedirect_url(String redirectUrl) {
		redirect_url = redirectUrl;
	}

	public String getTarget_url() {
		return target_url;
	}

	public void setTarget_url(String target_url) {
		this.target_url = target_url;
	}
}